package com.five;

import java.util.Scanner;

public class Demo9 {
    /*
    * 从键盘输入本次Java考试五位学生的成绩，求考试成绩最高分
    * */
    public static void main(String[] args) {
        //创建一个5个元素的数组
        double[] doubles = new  double[5];
        //创建键盘录入对象
        Scanner scanner = new Scanner(System.in);
        //接收5位学生成绩
        for (int i=0;i<5;i++){
            System.out.println("请输入第"+(i+1)+"位学生成绩：");
            double v = scanner.nextDouble();
            //每次都将成绩存入数组中
            doubles[i]=v;
        }
        System.out.println("----------------");
        //打印存入数组中的成绩
        for (int i = 0; i < doubles.length; i++) {
            System.out.print(doubles[i]+",");
        }
        //查找到最大值
        double max=doubles[0];
        for (int i = 1; i <doubles.length ; i++) {
                if(doubles[i]>max){
                    max=doubles[i];
            }
        }
        /*if(doubles[1]>max){
            max=doubles[1];
        }
        if(doubles[2]>max){
            max=doubles[2];
        }
        if(doubles[3]>max){
            max=doubles[3];
        }
        if(doubles[4]>max){
            max=doubles[4];
        }*/


        System.out.println("\n");
        System.out.println(max);
    }
}
